import request from "@/utils/request";
import {
  ContentTypeEnum,
  RequestCodeEnum,
  RequestMethodsEnum,
} from "@/enums/requestEnums";
const urlPrefix = "/xxl-job-admin";

/**
 * 删除执行器
 * @param params
 * @returns
 */
export function delJobGroup(params: any) {
  return request.get({ url: urlPrefix + "/jobgroup/remove?id=" + params });
}

/**
 * 详情
 * @param params
 * @returns
 */
export function detailJobGroup(params: any) {
  return request.get({ url: urlPrefix + "/jobgroup/loadById?id=" + params });
}

/**
 * 获取执行器 分页列表
 * @param params
 * @returns
 */
export function pageListJobGroup(params: any) {
  return request.get({ url: urlPrefix + "/jobgroup/pageList", params });
}
export function addJobGroup(params: any) {
  return request.post({ url: urlPrefix + "/jobgroup/save", params });
}

export function updateJobGroup(params: any) {
  return request.post({
    url: urlPrefix + "/jobgroup/update",
    params,
  });
}

//-------------任务管理-----------

/**
 * 任务管理 -获取首页枚举
 * @param params
 * @returns
 */
export function jobinfoIndex() {
  return request.get({ url: urlPrefix + "/jobinfo/index" });
}

export function pageListjobinfo(params: any) {
  return request.get({ url: urlPrefix + "/jobinfo/pageList", params });
}

export function addjobinfo(params: any) {
  return request.post({ url: urlPrefix + "/jobinfo/add", params });
}

export function updatejobinfo(params: any) {
  return request.post({ url: urlPrefix + "/jobinfo/update", params });
}
export function removejobinfo(params: any) {
  return request.get({ url: urlPrefix + "/jobinfo/remove?id=" + params });
}

export function stopjobinfo(params: any) {
  return request.get({ url: urlPrefix + "/jobinfo/stop?id=" + params });
}

export function startjobinfo(params: any) {
  return request.get({ url: urlPrefix + "/jobinfo/start?id=" + params });
}

/**
 * 执行一次
 * @param params
 * @returns
 */
export function triggerjobinfo(params: any) {
  return request.get({ url: urlPrefix + "/jobinfo/trigger", params });
}

/**
 * 下次执行时间
 * @param params
 * @returns
 */
export function nextTriggerTimejobinfo(params: any) {
  return request.get({ url: urlPrefix + "/jobinfo/nextTriggerTime", params });
}

//-----------------日志处理

export function jobLogIndex() {
  return request.get({ url: urlPrefix + "/joblog/index" });
}

export function pageListjobLog(params: any) {
  return request.get({ url: urlPrefix + "/joblog/pageList", params });
}
export function clearJobLog(params: any) {
  return request.get({ url: urlPrefix + "/joblog/clearLog", params });
}

/**
 * 终止任务
 * @param params
 * @returns
 */
export function logKillJobLog(params: any) {
  return request.get({ url: urlPrefix + "/joblog/logKill", params });
}

/**
 * 拉取日志
 * @param params
 * @returns
 */
export function logDetailCat(params: any) {
  return request.get({ url: urlPrefix + "/joblog/logDetailCat", params });
}

/**
 * 根据调度器查询任务
 * @param params
 * @returns
 */
export function getJobsByGroup(params: any) {
  return request.get({ url: urlPrefix + "/joblog/getJobsByGroup", params });
}
